<link href="./css/style.css" rel="stylesheet" type="text/css" />
<div class="main">
<div class="cashlist">
	<p class="tt"><a>首页</a>><a href="newslist.php">资讯管理</a>><span>资讯列表</span></p>
	<div class="list">
		{if($msg==1)}
		<table>
			<tr><th>ID</th><th>栏目</th><th>标题</th><th>图片</th><th>添加时间</th><th>状态</th><th>操作</th></tr>
		{loop $nlist $key as $list}
			<tr>
					<td>{$list[Id]}</td>
					<td>{$list[name]}</td>
					<td>{$list[title]}</td>
					<td class='pic'>
						{$pic = $list['pic1']}
						{for $i $pic}
						<img src='{$pic[$i]}' style="height:30px;" />
						{/for}
					</td>
					<td>{$list[addtime]}</td>
					<td>
						{if($list['state']==1)}
						<a class='abtn2 state' style='display:inline-block;float:none; width:auto; cursor:pointer;' data-id="{$list[Id]}">已发布</a>
						{else}
						<a class='abtn3 state' style='display:inline-block;float:none; width:auto; cursor:pointer; ' data-id="{$list[Id]}">审核中</a>
						{/if}
					</td>
					<td>
						<a class="abtn2" style="width:auto; float:none; display:inline-block;" href='news.php?nid={$list[Id]}'>编辑</a>
						<a class="abtn3" style="width:auto; float:none; display:inline-block;" onclick='del({$list[Id]})'>删除</a>
					</td>
				</tr>
		{/loop}
			</table>
		{$page1}
		{else}
		<p class='none'>未查询到相关信息</p>
		{/if}
	</div>
	<script src="./js/jquery.js"></script>
	<script>
		$(".pic").on("click",'img',function(){
			$(".pic img").removeClass('on');
			$(this).addClass('on');
		});
		$(".pic").on("click",'.on',function(){
			$(this).removeClass('on');
		});
		$(".state").on("click",function(){
			var e = $(this);
	       var id = e.attr('data-id');
	       $.ajax({
				type:"post",
				dataType:"json",
				url:"/Moudel.php?m=n&a=newsstate",
				data:"id="+id,
				success:function(d){
					if(d[0]==0){
						alert(d[1]);
					}else{
					    e.removeClass('abtn'+d[1]);
					    e.addClass('abtn'+d[2]);
					    e.html(d[3]);
					}
				}
			});
		});
		function del(id){
				$.ajax({
					type:"post",
					dataType:"json",
					url:"/Moudel.php?m=n&a=newsdel",
					data:"id="+id,
					success:function(d){
						if(d[0]==0){
							alert(d[1]);
						}
						else{
							alert(d[1]);
							window.location.href='newslist.php';
						}
					}
				});
			}
	</script>

</div>
</div>
<script>
	h1 = $(".main").height();
	h2 = $(".infolist").height();
	if(h2>h1){
		$(".main").css("height","auto");
	}
</script>